import { request } from "~~/utils/fetch";
import { reponseIntercept } from "@/utils";
import { HttpRequest } from "../utils/http";
const httpLog = new HttpRequest("log", 60000);
const http = new HttpRequest("bdc", 60000);

const isDev = () => {
  return process.env.NODE_ENV === "development";
};

// 后端-保存BDC日志
export const sendCommonMessage = http.Post(
  "/msa/api-activity/bdc/log/commonMessage"
);

/**
 * @description: 上报日志到服务端
 */
export const serveReport = httpLog.Post(isDev() ? "/servelog" : "/fx/servelog");

/**
 * @description: 获取日志
 */
export const getServeLog = httpLog.Post(
  isDev() ? "/getservelog" : "/fx/getservelog"
);
/**
 * @description: 发送代理请求
 */
export const sendProxy = httpLog.Post("/fx/sendProxy");

/**
 * @description: 删除日志
 */
export const removelog = httpLog.Get(isDev() ? "/removelog" : "/fx/removelog");
/**
 * @description: 获取/添加/删除 error 过滤信息
 */
export const errorkeyoperation = httpLog.Post(
  isDev() ? "/errorkey" : "/fx/errorkey"
);

/**
 * @description: 埋点信息上报
 */
export const trackReport = httpLog.Post(
  isDev() ? "/trackReport" : "/fx/trackReport"
);

/**
 * @description: 查询-埋点信息
 */
export const trackInfo = httpLog.Post(isDev() ? "/trackinfo" : "/fx/trackinfo");

/**
 * @description: 查询-埋点信息
 */
export const trackLogMetrics = httpLog.Post(
  isDev() ? "/trackinfoMetrics" : "/fx/trackinfoMetrics"
);

/**
 * @description: 文件下载
 */
// export const download = httpLog.Post(isDev() ? "/download" : "/fx/download", {
//   responseType: "blob",
// });
export const download = httpLog.Get(isDev() ? "/download" : "/fx/download");

/**
 * @description: 埋点-事件上报
 * */
export const analyticsEvent = httpLog.Post(
  isDev() ? "/analyticsEvent" : "/fx/analyticsEvent"
);
